import launch.launch_description_sources
import launch, launch_ros
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
    # 包含其他的launch文件
    action_include_launch_camera = launch.actions.IncludeLaunchDescription(
        launch.launch_description_sources.PythonLaunchDescriptionSource(
            [get_package_share_directory("hik_camera"), "/launch", "/hik_camera.launch.py"] 
        )
    )
    
    action_include_launch_armor = launch.actions.IncludeLaunchDescription(
        launch.launch_description_sources.PythonLaunchDescriptionSource(
            [get_package_share_directory("rm_auto_aim"), "/launch", "/demo.launch.py"]
        )
    )
    # 执行命令行
    # action_executeprocess = launch.actions.ExecuteProcess()
    
    # 输出日志
    action_log_info_camera = launch.actions.LogInfo(msg = '开启海康相机')
    # action_log_info_detector = launch.actions.LogInfo(msg = '搜索装甲板')
    # action_log_info_tracker = launch.actions.LogInfo(msg = '开启跟踪')
    
    # 封装成组合
    action_group = launch.actions.GroupAction([launch.actions.TimerAction(period = 2.0, actions = [action_log_info_camera]), 
                                               launch.actions.TimerAction(period = 3.0, actions = [action_include_launch_armor]), 
                                            #    launch.actions.TimerAction(period = 4.0, actions = [action_log_info_detector]), 
                                            #    launch.actions.TimerAction(period = 4.0, actions = [action_log_info_tracker])
                                               ])
    
    launch_description = launch.LaunchDescription([action_include_launch_camera, action_group])
    
    return launch_description
    